<template>
	<view class="container">
		<input v-model="value" class="input" type="text" />
		<view style="margin-top: 50rpx;">
			<q-button @click="submit">保存</q-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				field: '',
				value: '',
				addValue: ''
			};
		},
		onLoad(options) {
			this.field = options.field;

			if (options.field == "tag_str") {
				this.value = [];
			}

			if (options.value) {
				this.value = JSON.parse(options.value);
			}
		},
		methods: {
			submit() {
				uni.showLoading({
					mask: true,
					title: '正在保存'
				});

				this.$H.post('user/setInfo', {
					field: this.field,
					value: this.value
				}).then(res => {
					if (res.code == 200) {
						uni.navigateBack();
					}

					uni.hideLoading();
				});
			}
		}
	};
</script>

<style lang="scss">
	page {
		background-color: #f5f5f5;
	}

	.input {
		border-bottom: 1px solid #e2e2e2;
		padding: 10rpx;
	}

	.tag-add {
		padding: 20rpx;
		background-color: #f5f5f5;
		width: 60rpx;
		height: 60rpx;
		border-radius: 50%;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>